﻿@{
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
    ViewBag.Title = "系统功能管理";
}
<div class="header">
    <h1>@ViewBag.Title</h1>
</div>
<ul class="breadcrumb">
    <li>@Html.ActionLink("Home", "Index", "Home")</li>
    <li>@Html.ActionLink("System Function", "Index", "Function")</li>
    <li class="active">System Function</li>
</ul>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="btn-toolbar" id="toolbar">
            <a class="btn btn-primary" href="@Url.Action("Create",new {parentId =Request["pId"] })" data-toggle="modal" data-target="#modalEdit">
                <i class="fa fa-plus"></i> 添加 功能入口
            </a>
            @if (Request["parentId"] != "0")
            {
                <a class="btn btn-primary" href="@Url.Action("Index", new {pid=Request["ppId"]})">
                    <i class="fa fa-plus"></i> 返回上一级
                </a>
            }
            <div class="btn-group">
            </div>
        </div>

        <div class="well">
            <table id="table"
                   data-url="@Url.Action("List", new {pId = Request["pId"]})"
                   data-side-pagination="server"
                   data-toggle="table"
                   data-height="400"
                   data-show-refresh="true"
                   data-minimum-count-columns="2"
                   data-id-field="id"
                   data-page-list="[10, 25, 50, 100, ALL]"
                   data-search="true">
                <thead>
                <tr>
                    <th data-field="state" data-checkbox="true"></th>
                    <th data-field="Name" data-align="center" data-sortable="true">显示名称</th>
                    <th data-field="Order" data-align="center" data-sortable="true">排序</th>
                    <th data-field="Type" data-align="center" data-sortable="true">类型</th>
                    <th data-field="ActionUrl" data-sortable="true" data-sorter="priceSorter">请求地址</th>
                    <th data-field="Operator" data-sortable="true" data-sorter="priceSorter">操作人</th>
                    <th data-field="OperationTime" data-sortable="true" data-sorter="trur">操作时间</th>
                    <th data-field="operate" data-formatter="operateFormatter" data-events="operateEvents">操作</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>




@section scripts{
    <script>
        var $table = $('#table');

        function operateFormatter(value, row, index) {
            if (row.Id > 0) {
                return [
                    '<a class="sub ml10" href="javascript:void(0)" title="子菜单">',
                    '<i class="glyphicon glyphicon-search"></i>',
                    '</a>',
                    '<a class="edit ml10" href="javascript:void(0)" title="编辑">',
                    '<i class="glyphicon glyphicon-edit"></i>',
                    '</a>',
                    '<a class="remove ml10" href="javascript:void(0)" title="删除">',
                    '<i class="glyphicon glyphicon-remove"></i>',
                    '</a>'
                ].join('');
            } else {
                return [
                    '<a class="add ml10" href="javascript:void(0)" title="添加">',
                    '<i class="glyphicon glyphicon-plus"></i>',
                    '</a>'
                ].join('');
            }
        }


        window.operateEvents = {
            'click .edit': function(e, value, row, index) {
                $("#modalEdit").modal({ remote: '@Url.Action("Edit")?id=' + row.Id });
            },
            'click .remove': function(e, value, row, index) {
                $("#modalEdit").modal({ remote: '@Url.Action("Delete")?id=' + row.Id });
            },
            'click .sub': function(e, value, row, index) {
                window.location.href = '@Url.Action("Index")?ppId=@Request["pId"]&pId=' + row.Id;
            },
            'click .add': function(e, value, row, index) {
                $('#modalEdit').modal({
                    remote: "@Url.Action("Create", new {parentId = Request["pId"]})"
                });
            }

        }
  


        function OnSuccess(result) {
            if (result.success) {
                $('#modalEdit').modal('hide');
                $table.bootstrapTable('refresh');

            } else {
                $('#modalEditContent').html(result);
            }
        }

        function getHeight() {
            return $(window).height() - $('h1').outerHeight(true);
        }

        $(function() {
            $("#modalEdit").on("hidden.bs.modal", function() {
                $(this).removeData("bs.modal");
            });
        });
    </script>
}
